/*============================================================================*/
/*                   CONTINENTAL AUTOMOTIVE SYSTEMS                           */
/*============================================================================*/
/*                        OBJECT SPECIFICATION                                */
/*============================================================================*
* name:            MALPIT_Init.h
* version:         1.1
* created_by:      Lizette Acosta/Rodrigo Casados
* date_created:    June 22 2013
*=============================================================================*/

#ifndef MALPIT_INIT_H
#define MALPIT_INIT_H


/*****************************************************************************************************
* Include files
*****************************************************************************************************/

#include "typedefs.h"
#include "stdtypedef.h"


/* PIT_Callback[], function to be called upon event trigger on PIT channels */
extern tCallbackFunction PIT_Callback[2];
	

/** Periodic Interrupt Timer definitions */
#define    PIT_CHANNEL_0_10ms				0
#define    PIT_CHANNEL_1_100ms				1

#define    PIT_CALLBACK_0					0
#define    PIT_CALLBACK_1					1

#define    PIT_DEVICE_FREQUENCY           (uint32_t)64000000

/****************************************************************************************************/
/* Values for 10ms PIT Timer*/
/****************************************************************************************************/
#define    PIT_CHANNEL_1_TARGET_FREQUENCY   (uint32_t)2000

/** Periodic Interrupt Timer macros */
#define    PIT_CHANNEL_1_VALUE            	( ( PIT_DEVICE_FREQUENCY / PIT_CHANNEL_1_TARGET_FREQUENCY ) - 1 )

/* Flag to modify for Debouncer (10ms PIT timer) */
extern gub_DebouncerFlag;


/****************************************************************************************************/
/* Values for 100ms PIT Timer*/
/****************************************************************************************************/
#define    PIT_CHANNEL_2_TARGET_FREQUENCY   (uint32_t)100000

/** Periodic Interrupt Timer macros */
#define    PIT_CHANNEL_2_VALUE            	( ( PIT_DEVICE_FREQUENCY / PIT_CHANNEL_2_TARGET_FREQUENCY ) - 1 )



/** PIT Low level initialization */
void PIT_device_init(void);

/* PIT Install Interrupt routine for channels 0 and 1 */
void PIT_InstallInt(void);

/* PIT Low level channel configuration */
void PIT_channel_configure(uint8_t channel, tCallbackFunction Callback);

/** PIT Low level Start procedure */
void PIT_channel_start(uint8_t channel);

/** PIT Low level Stop procedure */
void PIT_channel_stop(uint8_t channel);

/** PIT Channel 0 ISR  */
void PIT_channel_0_isr( void  );

/** PIT Channel 1 ISR  */
void PIT_channel_1_isr(void);



/*******************************************************************************/

#endif /* MALPIT_INIT_H  */
